package com.zhongge.comparerelevant.comparable;

/**
 * @ClassName Student
 * @Description TODO
 * @Author zhongge
 * @Version 1.0
 */
public class Student implements Comparable<Student>{
    private String name;//学生姓名
    private int age;//学生年龄

    //使用快捷键生成构造函数和toString方法
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Student o) {
//        return this.age - o.age;
        return this.name.compareTo(o.name);
    }
}
